home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr11 / pdox693.zip / TI1311.ASC < prev    next >
Text File  |  1993-03-18  |  6KB  |  199 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.   PRODUCT  :  Paradox                               NUMBER  :  1311
  8.   VERSION  :  All
  9.        OS  :  DOS
  10.      DATE  :  March 18, 1993                           PAGE  :  1/3
  11.  
  12.     TITLE  :  Using a Changeto Query to Transfer Data From One
  13.               Table to Another
  14.  
  15.  
  16.  
  17.  
  18.   Intended Audience:
  19.   This technical information sheet is intended for Paradox users of
  20.   all levels.
  21.  
  22.   Purpose:
  23.   The purpose of this technical information sheet is to explain the
  24.   process of performing a Changeto Query to copy data from one
  25.   table to another.
  26.  
  27.  
  28.   There are a number of ways to move or copy records from one table
  29.   to another.  Some examples are:
  30.  
  31.       -  Tools | More | Add | Update.  Modifies the target table by
  32.          updating existing records or adding new records to it.
  33.          This is the easiest technique; however, it requires that
  34.          the table structures be identical.
  35.  
  36.       -  Insert queries - Lets you add new records to a table.
  37.  
  38.       -  Changeto queries - To change specific fields in a table.
  39.  
  40.       -  PAL scripts
  41.  
  42.   This document discusses how to use a Changeto query to copy data
  43.   from selected non-linking fields in one table to another table.
  44.   Changeto queries are useful in situations where the table
  45.   structures are different, or you do not want to update all the
  46.   fields in a table.
  47.  
  48.   To perform a Changeto query there must be at least one linking
  49.   field between the tables (a field of the same type), as well as
  50.   matching field values between the linking field(s) in the tables.
  51.   If there is no matching field value for a given record, Paradox
  52.   cannot establish a link between the records and the copy will not
  53.   be performed.  If there are no link values between the tables, an
  54.   Insert query can be performed to add data from one table to
  55.   another.
  56.  
  57.   Suppose you want to update the Last Name field in the Orders
  58.   table from the Employee table.  The first step would be to
  59.   restructure the Orders table and add a Last Name field to it.  Do
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.   PRODUCT  :  Paradox                               NUMBER  :  1311
  74.   VERSION  :  All
  75.        OS  :  DOS
  76.      DATE  :  March 18, 1993                           PAGE  :  2/3
  77.  
  78.     TITLE  :  Using a Changeto Query to Transfer Data From One
  79.               Table to Another
  80.  
  81.  
  82.  
  83.  
  84.   this by choosing Modify | Restructure from the Main menu.  Bring
  85.   up a query form for each table by choosing Ask from the Main
  86.   menu.
  87.  
  88.   EMPLOYEE╦═══Emp #════╦═══Last Name════╦═══Init═══╦══Position══╗
  89.           ║            ║                ║          ║            ║
  90.           ║            ║                ║          ║            ║
  91.  
  92.   ORDERS╦══Cust #═══╦═══Date════╦═══Item═══╦══Emp#══╦══Last Name══╗
  93.         ║           ║           ║          ║        ║             ║
  94.         ║           ║           ║          ║        ║             ║
  95.    
  96.   To build the query, link the tables on the common field, Emp #.
  97.   Link them by placing an example element in the Emp # field of
  98.   both query forms.  Place an example element by pressing F5 and
  99.   then typing in an expression.  The example element can be almost
  100.   anything, as long as it is the same in both two query forms.  By
  101.   placing the same example element in both query forms, you have
  102.   informed Paradox that these fields are linking fields.
  103.  
  104.   Next, place an example element in the Last Name field of the
  105.   source (Employee) table.  This example element can be anything
  106.   except for the example element which was used in the linking
  107.   fields (in this example, the Emp# field).  After placing this
  108.   example element, move to the Last Name field in the destination
  109.   table (in this example, Orders).  Type the word CHANGETO, a
  110.   space, and then the same example element which was placed in the
  111.   Last Name field of the Employee query form.  At this point, the
  112.   tables are linked, the second example element has been used to
  113.   represent the contents of the Last Name field in the source
  114.   table, and the CHANGETO expression has been typed into the Last
  115.   Name field in the destination table.
  116.  
  117.   The query forms should look like this.
  118.  
  119.   EMPLOYEE╦═══Emp #════╦═══Last Name════╦═══Init═══╦══Position══╗
  120.           ║    _A      ║      _B        ║          ║            ║
  121.           ║            ║                ║          ║            ║
  122.  
  123.   ORDERS╦══Cust #═══╦═══Date════╦═══Item═══╦══Emp#══╦══Last Name══╗
  124.         ║           ║           ║          ║   _A   ║ CHANGETO _B ║
  125.         ║           ║           ║          ║        ║             ║
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.   PRODUCT  :  Paradox                               NUMBER  :  1311
  140.   VERSION  :  All
  141.        OS  :  DOS
  142.      DATE  :  March 18, 1993                           PAGE  :  3/3
  143.  
  144.     TITLE  :  Using a Changeto Query to Transfer Data From One
  145.               Table to Another
  146.  
  147.  
  148.  
  149.  
  150.   Note: The underscore character "_" in the query forms on the
  151.         previous page, represents an example element.
  152.  
  153.   The query is now ready to process.  To process the query, press
  154.   F2.
  155.  
  156.   When the query is finished processing, a CHANGED table will
  157.   appear on screen.  This table contains the records of the
  158.   destination table in the state that they were in before the query
  159.   was processed.  Paradox provides this table as a backup.  It is a
  160.   temporary table and it will be deleted when you exit Paradox, or
  161.   overwritten if you perform another CHANGETO query.  By viewing
  162.   the table, you will be able to now see the updated records which
  163.   correspond to the records in the CHANGED table.
  164.  
  165.  
  166.   For additional information on Changeto and Insert queries, refer
  167.   to the Chapter 6 of the User's Guide (for versions 3.5 and
  168.   earlier, refer to Chapter 4 of the User's Guide).
  169.  
  170.  
  171.   DISCLAIMER: You have the right to use this technical information
  172.   subject to the terms of the No-Nonsense License Statement that
  173.   you received with the Borland product to which this information
  174.   pertains.
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.